﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using System.IO;
using System.Text;

public partial class User_Shares_ProjectStatusDetails : System.Web.UI.Page
{
    protected void Page_Load( object sender, EventArgs e )
    {
        if ( !Page.IsPostBack )
        {
            if ( Session[ "ContractId" ] != null )
            {
                var contractId = new Guid( Session[ "ContractId" ].ToString() );
                //GridViewProjectDetails.DataSource = ProjectTaskDetails.GetAllSteps( new Guid( Session[ "ContractId" ].ToString() ) );
                 GridViewProjectDetails.DataSource = ProjectTaskDetails.GetAllSteps( new Guid( Session[ "ContractId" ].ToString() ) );
              
                string doer = Business.CommonCalculations.FindDoerOfProject( contractId );
                string villageName = Business.CommonCalculations.VillageNameByContractId( contractId );
                string contractType = Business.CommonCalculations.ContractTypeNameString( contractId );
                string fourthFactorName = Business.CommonCalculations.FindFourthFactorByContractId(contractId);
                string cityName = Business.CommonCalculations.CityNameByContractId(contractId);

                LabelDoer.Text = string.Format( "مشاور / نقشه بردار : {0}", doer );
                LabelVillageName.Text = string.Format( "نام روستا: {0}", villageName );
                LabelContractType.Text = string.Format( "نوع قرارداد: {0}", contractType );
                LabelFourthFactor.Text = string.Format("عامل چهارم: {0}", fourthFactorName);
                LabelCityName.Text = string.Format("شهرستان:{0}", cityName);
            }
            Page.DataBind();
        }
    }


    protected void GridViewProjectDetails_RowDataBound( object sender, GridViewRowEventArgs e )
    {
        var user=HttpContext.Current.User;
        if (user.IsInRole("bonyadshahrestan"))
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label s = e.Row.FindControl("LabelStepName") as Label;
                string[] split = s.Text.Split(new char[] { '.' });
                for (int i = 7; i <= 17; i++)
                    if (split[0] == i.ToString())
                        e.Row.Enabled = false;
            }
        }
    }
    
}